//
// System.Globalization.CultureNotFoundException.cs
//
// Authors:
//	Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (c) 2010 Novell (http://www.novell.com)
//

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#ifndef CultureNotFoundException_h
#define CultureNotFoundException_h

#include <System/ISerializable.h>
#include <System/ArgumentException.h>
#include <System/ArgumentNullException.h>
#include <System/Nullable.h>

namespace Riccsson
{
    namespace System
    {
        namespace Globalization
        {
	        class CultureNotFoundException : public ArgumentException, public ISerializable
			{
		        GC_PTR<string> invalid_culture_name;
		        Nullable<int> invalid_culture_id;

		        public: CultureNotFoundException () : ArgumentException ("Culture not found")
		        {
		        }

		        public: CultureNotFoundException (string* message) : ArgumentException (message)
		        {
		        }

		        protected: CultureNotFoundException (SerializationInfo* info, StreamingContext* context)
				        : ArgumentException (info, context)
		        {
			        invalid_culture_name = (string*) info->GetValue ("invalid_culture_name", typeof (string));
			        invalid_culture_id = (Nullable<int>*) info->GetValue ("invalid_culture_id", typeof (int?));
		        }

		        public: CultureNotFoundException (string* message, Exception* innerException)
				        : ArgumentException (message, innerException)
		        {
		        }

		        public: CultureNotFoundException (string* paramName, string* message)
				        : ArgumentException (message, paramName)
		        {
		        }

		        public: CultureNotFoundException (string* message, int invalidCultureId, Exception* innerException)
				        : ArgumentException (message, innerException)
		        {
			        invalid_culture_id = invalidCultureId;
		        }

		        public: CultureNotFoundException (string* paramName, int invalidCultureId, string* message)
				        : ArgumentException (message, paramName)
		        {
			        invalid_culture_id = invalidCultureId;
		        }

		        public: CultureNotFoundException (string* message, string* invalidCultureName, Exception* innerException)
				        : ArgumentException (message, innerException)
		        {
			        invalid_culture_name = invalidCultureName;
		        }

		        public: CultureNotFoundException (string* paramName, string* invalidCultureName, string* message)
				        : ArgumentException (message, paramName)
		        {
			        invalid_culture_name = invalidCultureName;
		        }

		        public: override void GetObjectData(SerializationInfo* info, StreamingContext* context)
		        {
			        if (info == null)
				        throw ArgumentNullException ("info");

			        ArgumentException::GetObjectData (info, context);
			        info->AddValue ("invalid_culture_name", invalid_culture_name, typeof (string));
			        info->AddValue ("invalid_culture_id", invalid_culture_id, typeof (int?));
		        }

		        public: virtual PROP3_GET(Nullable<int>, InvalidCultureId)
			    {
					return invalid_culture_id;
		        }

		        public: virtual PROP3_GET(GC_PTR<string>, InvalidCultureName)
			    {
					return invalid_culture_name;
		        }

		        public: override PROP3_GET(GC_PTR<string>, Message)
			    {
				    if (invalid_culture_name == null && invalid_culture_id.HasValue == false)
					    return base.Message;

				    if (invalid_culture_name != null)
					    return String::Format ("Culture name {0} is invalid", invalid_culture_name);
				    return String::Format ("Culture ID {0} is invalid", invalid_culture_id);
		        }
	        };
        }
	}
}

#endif